import { createApp } from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
// 2. 引入组件样式
import 'vant/lib/index.css';
// 1.引入组件库
import Vant from 'vant';
import VueLazyloadNext from 'vue-lazyload-next'
const loadimage = require('./assets/logo.png')
const errorimage = require('./assets/error.png')

// 注册vant组件库 .use(Vant)

// 把应用实例赋值给全局变量
const app = createApp(App)
// 全局自定义指令

// 自定义指令1：v-focus
app.directive('focus', {
    mounted: (el) => el.focus()
})

// 自定义指令2：v-preventclick
app.directive('preventclick', {
    beforeMount: (el) => {
        el.addEventListener('click', () => {
            el.disabled = true
            setTimeout(() => {
                el.disabled = false
            }, 2000)
        })
    }
})


app.use(Vant).use(store).use(router).use(
    VueLazyloadNext,
    {
        preLoad: 1.3,
        error: errorimage,
        loading: loadimage,
        attempt: 1
    }
).mount('#app')
